/**
 * @file common.h
 * @brief VimL虚拟机公共定义和类型
 * @author VimLVM Team
 * @date 2025
 */

#ifndef VIML_COMMON_H
#define VIML_COMMON_H

#include <cstdint>
#include <vector>
#include <string>
#include <memory>

namespace viml {

// 基本类型定义
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

// 虚拟机常量
constexpr size_t MAX_REGISTERS = 256;
constexpr size_t MAX_STACK_SIZE = 1024;
constexpr size_t MAX_FRAMES = 256;

// 错误码定义
enum class ErrorCode {
    SUCCESS = 0,
    TYPE_ERROR,
    MEMORY_ERROR,
    DIVISION_BY_ZERO,
    INDEX_OUT_OF_BOUNDS,
    UNDEFINED_VARIABLE,
    INVALID_OPCODE,
    STACK_OVERFLOW,
    STACK_UNDERFLOW,
    INVALID_ARGUMENT
};

// 前向声明
class Value;
class VM;
class Instruction;
class Compiler;
class Debugger;

} // namespace viml

#endif // VIML_COMMON_H